package com.ybfenpan.controller.admin.center;

import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.ybfenpan.controller.core.BaseController;
import com.ybfenpan.model.Member;
import com.ybfenpan.model.center.RequestCenter;
import com.ybfenpan.service.MemberService;
import com.ybfenpan.service.center.RequestCenterService;
import com.ybfenpan.utils.MapUtil;

/**
 * Created by Administrator on 2016/3/25.
 */
@Controller
public class RequestCenterCommitController extends BaseController {
	@Resource
	private RequestCenterService requestCenterService;

	@Resource
	private MemberService memberService;

	@RequestMapping("admin/center/requestCenterCommitShow.shtml")
	public String show(ModelMap model, HttpServletRequest request, HttpServletResponse response) throws Exception {

		Map formMap = getParameterMap(request);
		int id = MapUtil.getIntValue(formMap, "id");
		RequestCenter one = (RequestCenter) this.requestCenterService.getByKey(id);
		request.setAttribute("one", one);

		Member member = this.memberService.getByKey(one.getMemberId());

		request.setAttribute("memberLoginName", member.getLoginName());

		return "admin/center/requestCenterCommit";

	}

	@RequestMapping("admin/center/requestCenterCommit.shtml")
	public String add(ModelMap model, HttpServletRequest request, HttpServletResponse response) throws Exception {

		Map formMap = getParameterMap(request);
		int id = MapUtil.getIntValue(formMap, "id");
		RequestCenter one = (RequestCenter) this.requestCenterService.getByKey(id);
		requestCenterService.updateCommitOne(one);

		return "redirect:requestCenterList.shtml";

	}

}
